package com.sskj.functions.presenter;


import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.functions.activity.ShiftToActivity;
import com.sskj.functions.presenter.BasePresenter;
import com.sskj.lib.bean.CurrentTreasureBean;
import com.sskj.lib.bean.CurrentTypeBean;
import com.sskj.lib.bean.ShiftBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;

/**
 * @author Hey
 * Create at  2019/06/26
 */
public class ShiftToPresenter extends BasePresenter<ShiftToActivity> {

    public void getShiftToData(String tv, String ptype) {
        httpService.getShiftToData(tv, ptype)
                .tag(this)
                .execute(new JsonCallBack<HttpData<ShiftBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<ShiftBean>> response) {
                        ShiftBean data = response.body().getData();
                        mView.getShiftToData(data);
                    }
                });
    }

    //转入
    public void getShiftTo(String type, String price, String pwd) {
        httpService.shiftToMoney(type, price, MD5Util.getFiveMd5Value(pwd))
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {

                        mView.getShiftToSuccess();
                    }
                });
    }

    //转出
    public void getRollOut(String type, String price, String pwd) {
        httpService.getRollOut(type, price, MD5Util.getFiveMd5Value(pwd))
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.getShiftToSuccess();
                    }
                });
    }

    public void getCurrentType() {
        httpService.getCoinList()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<String>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<String>>> response) {
                        mView.getCoinListOK(response.body().getData());
                    }
                });
    }
}
